<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./Promise.js"></script>
</head>
<body>
    <h1>手写Promise的异步应用</h1>

    <script>
         
        // 实例化一个自定义的Promise对象
        const p = new Promise((resolve, reject) => {
            setTimeout(()=>{
                console.log(111);
                 resolve("ok");
                //reject("error");
            },3000);
            
        });

        console.log(p);
        // 使用对象设置回调
        p.then(value=>{
            console.log("成功",value);
        },reason => {
            console.log("失败",reason);
        });

        p.then(value=>{
            console.log("成功2",value);
        },reason => {
            console.log("失败2",reason);
        });
        console.log(222);

    </script>
</body>
</html>